import 'package:easy_read_comic/internal/http_client.dart';
import 'package:dio/dio.dart';

class UserApi {
  // 静态变量来保存唯一的实例
  static final UserApi _instance = UserApi._internal();

  // 私有构造函数
  UserApi._internal();

  // 工厂构造函数
  factory UserApi() {
    return _instance;
  }

  // login 登录
  Future<Response> login(String email, String password) async {
    return HttpClient().post("/v1/user/login", data: {
      "email": email,
      "password": password,
    });
  }

  // register 注册
  Future<Response> register(String email, String code, String password) async {
    return HttpClient().post("/v1/user/register", data: {
      "email": email,
      "code": code,
      "password": password,
    });
  }
}
